struct Window {
	HWND		handle;
	WNDCLASSEX	wndclass;

	HDC			deviceContext;
	HGLRC		renderContext; 

	short width, height;

	Window ():
		width	(0),
		height	(0)
	{}
	//

	~Window () {}
	//

	void setup (WNDPROC wndProc, 
				HINSTANCE hInstance, 
				char const * windowName, 
				int _width , 
				int _height)
	{
		width  = _width;
		height = _height;

		// set up the wndclass
		wndclass.lpfnWndProc	= wndProc;		// mandatory: Window Procedure
		wndclass.hInstance		= hInstance;	// mandatory: owner of the class
		wndclass.lpszClassName	= windowName;	// mandatory: name of the class
		wndclass.cbSize			= sizeof(WNDCLASSEX);
		wndclass.style			= 0;
		wndclass.cbClsExtra		= 0;
		wndclass.cbWndExtra		= 0;
		wndclass.hIcon			= 0;
		wndclass.hCursor		= 0;	
		wndclass.hbrBackground	= 0;	
		wndclass.lpszMenuName	= 0;

		// register the wndclass
		RegisterClassEx (&wndclass);

		short topCornerX = (GetSystemMetrics(SM_CXSCREEN) - width) / 2;
		short topCornerY = (GetSystemMetrics(SM_CYSCREEN) - height)/ 2;

		// build the window
		handle = CreateWindowEx(
			NULL,								// extended window style
			windowName,							// name of a registered window class
			"",									// window caption
			WS_VISIBLE | WS_OVERLAPPEDWINDOW,	// window style
			topCornerX,							// x position
			topCornerY,							// y position
			width,								// witdh
			height,								// height
			0,									// handle to parent window
			0,									// handle to menu
			hInstance,							// application instance
			0									// window creation data
		);

		// get a device context
		deviceContext = GetDC(handle);

		// set the pixel format descriptor
		setPixelFormatDescriptor( deviceContext );

		// get a render context
		renderContext = wglCreateContext(deviceContext);
		wglMakeCurrent(deviceContext, renderContext);
	}
	//

	void resize(int xsize, int ysize) {
		width = xsize; 
		height = ysize;

		// clear the old render context
		wglMakeCurrent( NULL, NULL );
		wglDeleteContext( renderContext );

		// get a new one
		renderContext = wglCreateContext(deviceContext);
		wglMakeCurrent(deviceContext, renderContext);
	};


	void shutDown () {
		wglMakeCurrent( NULL, NULL );
		wglDeleteContext( renderContext );
		ReleaseDC( handle, deviceContext );
	}
	//

	bool setPixelFormatDescriptor (HDC hdc) {
		PIXELFORMATDESCRIPTOR pfd;

		pfd.cAccumBits = 0;
		pfd.cAccumAlphaBits = 0;
		pfd.cAccumBlueBits = 0;
		pfd.cAccumGreenBits = 0;
		pfd.cAccumRedBits = 0;
		pfd.cAlphaBits = 8;
		pfd.cAuxBuffers = 0;
		pfd.cColorBits = 32;
		pfd.cDepthBits = 24;
		pfd.cStencilBits = 0;
		pfd.dwFlags = PFD_DOUBLEBUFFER | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW;
		pfd.iLayerType = PFD_MAIN_PLANE;
		pfd.iPixelType = PFD_TYPE_RGBA;
		pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
		pfd.nVersion = 1;

		// choose pixel format returns the number most similar pixel format available
		int n = ChoosePixelFormat(hdc, &pfd);

		// set pixel format returns whether it sucessfully set the pixel format
		return SetPixelFormat(hdc, n, &pfd);
	}
	//

};


